lectures.alex.balgavy.eu

Lecture notes from university.
git clone git://git.alex.balgavy.eu/lectures.alex.balgavy.eu.git
Log | Files | Refs | Submodules

Program-controlled I_O.html (2747B)


      1 <?xml version="1.0" encoding="UTF-8"?>
      2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      3 <html><head><link rel="stylesheet" href="sitewide.css" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="exporter-version" content="Evernote Mac 6.13.1 (455785)"/><meta name="altitude" content="-0.09754352271556854"/><meta name="author" content="Alex Balgavy"/><meta name="created" content="2017-12-17 1:34:08 PM +0000"/><meta name="latitude" content="52.37355729316155"/><meta name="longitude" content="4.836194589138463"/><meta name="source" content="desktop.mac"/><meta name="updated" content="2017-12-17 1:34:15 PM +0000"/><title>Program-controlled I/O</title></head><body><div>“a program that performs all functions needed to realise the desired action”</div><div>difference in speed between processor and I/O devices, need to synchronise transfer of data</div><div>solution — signalling protocol (wait for signal from device, a status flag)</div><div>polling — checking the device’s status flag</div><div><br/></div><div><span style="font-weight: bold;">Example: RISC-style I/O</span></div><div>reads from keyboard, echoes back to display. end on newline</div><div><br/></div><ol><li>Point register R2 to address of first location in main memory where read characters will be stored</li><li>Load newline character (terminator) into R3</li><li>Start input loop</li><ol><li>Move keyboard status into R4</li><li>R4 = R4 AND #2</li><ul><li>the KIN status flag is the second byte of the value in R4 — so R4 looks like ...0X or …1X</li><li>#2 is 10 in binary</li><li>ANDing them together gives you the state of the KIN flag (i.e. 0X AND 10 = 0X)</li></ul><li>If [R4] is 0 (KIN is false), jump to step 1 of loop</li></ol><li>Load KBD_DATA byte into R5 (clearing KIN to 0)</li><li>Store R5 into address in R2</li><li>Increment pointer in R2 (to store next character)</li><li>Start output loop</li><ol><li>Load DISP_STATUS byte into R4</li><li>R4 = R4 AND #2</li><ul><li>the DOUT flag is the third byte of the value in R4 — so R4 is either …0XX or …1XX</li><li>#4 is 100 in binary</li><li>ANDing them together gives you the state of the DOUT flag (i.e. 0XX AND 100 = 0XX)</li></ul><li>If [R4] is 0, jump to step 1 of loop</li></ol><li>Store byte in R5 into DISP_DATA</li><li>If the Terminator isn’t in R5 ([R5] ≠ [R3]), jump to step 3 (input loop)</li></ol><div><br/></div><div><br/></div><div><img src="Program-controlled%20I_O.resources/screenshot_1.png" height="256" width="834"/></div><div><br/></div><div><img src="Program-controlled%20I_O.resources/screenshot.png" height="251" width="828"/></div><div><br/></div></body></html>